package Bondarenko.algorithm;


//In program rounding to integer value


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


import Bondarenko.algorithm.calc.Array;
import Bondarenko.algorithm.gen.GACrossingString;



public class Main {
	
 static boolean isInteger(String str) {
	    try {
	        Integer.parseInt(str);
	        return true;
	    } catch (NumberFormatException nfe) {}
	    return false;
	}
	
	 public static void main(String[] args) throws IOException {

		
		String str;
		
		do
        {
			System.out.print("Enter number of elements(>=2): ");
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			 str = input.readLine();
        } while (isInteger(str) != true || Integer.parseInt(str) < 2);

        	 
        	
              Array.arraySize =Integer.parseInt(str);
              
              int[] array = new int[Array.arraySize];
        	 
             array = Array.RandomArray(Array.arraySize);
             int rand = (int) Math.floor(Math.random() * 1000);
        	
        	 
        	 for(int i = 0; i <  Array.arraySize; i++) {
        		 System.out.print(array[i] + " ");
       		  }
        	 System.out.print("= "+rand+" ");
        	 System.out.println();
        	 System.out.println("Result:");
        	 
        	 GACrossingString.TARGET = rand;
        	 GACrossingString.SIZE = Array.arraySize;
        	 GACrossingString.ARRAY = array;
        	 
        	 new GACrossingString().go();
         }
         
	
}
        
   
